/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gruppe1projekt.GUILayer;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author Moulde
 */
public class ImagePanel extends JPanel
{
    private BufferedImage image;
    private int width;
    private int height;

    public ImagePanel(String path)
    {
        try
        {
            image = ImageIO.read(new File(path));
            height = image.getHeight();
            width = image.getWidth();
        }
        catch (IOException ex)
        {
            System.out.println(ex.toString());
        }

        this.setBackground(Color.red);
    }

    @Override
    protected void paintComponent(Graphics g)
    {
        g.drawImage(image, 0,0,getWidth(), getHeight(), null);
    }

    public int getHeight()
    {
        return height;
    }

    public void setHeight(int height)
    {
        this.height = height;
    }

    public int getWidth()
    {
        return width;
    }

    public void setWidth(int width)
    {
        this.width = width;
    }
}
